Fixed most errors, need to fix FSM