Abstract out state logic

- This PR abstracts out the all state-specific logic to a separate modules
- Tested manually on staging with success
- Rebased against master

(Note: this PR does **not** implement a new state yet.)