complete rewrite of app state machine
skeleton for history storage