Code! Still not as clean as I'd like it to be, and not quite complete, and completely untested, but it's a start.