Refactored mainState()

Cleaned up create() function by adding new methods.
Renamed main_state() to mainState.