added AppStates and cleaned up