Function pointer based finite state machine.