expanded out the state machine just to see some best practices
refactored mode management out and developed a mode stack
moved machine states to their own location
refactoring how i/o works
added routines to update output buffers