Refactor states into multiple files