Refactor.

Pull code into subs, use keys instead of top level vars.
Improve error reporting so that undocumented opcodes appear only
once as errors no matter how many vms they are undocumented for.