Finished backend of building State Machine.