Some cleanup of dead code, and some renaming.
Removed the emulation code.
Will integrate this into the main code as a flag or so later.
Removed globals and turn dicts into objects.
Working version with callbacks.