Before merge with Jesun's code

Things are mostly finished except for error checking and the ."anything
before ORIG is a comment" thing.