fixed a bug in state machine, updated some docs and added abstract state