Added FSM, cleaned up more