Easy problem once I figured out the trick to constructing an inherently stateful structure with backwards pointer references (at least the first way I would've made it) into a functional alist solution. Very cool.
Not complete, dunno what to do for parsing and handling CD commands.