Pull out state machine into transfer_machine.js.