Issue #6. Fixed restoring state on restart.