Refactored states. Fixed null pointer on back pressed.