Cleaned up control loop.  Also added basic undo/redo functionality