Clean up.  Modes and variables structured as dicts