Mass refactor to new state system

Signed-off-by: Ian Macalinao <me@ian.pw>