Allow overriding defines, fix cut-n-paste error.
More work on the state machine.