Moved changeState to the machine class and cleaned up some unnecessary methods in machine class