Implement internal state machine with no transaction required

https://bugzilla.redhat.com/show_bug.cgi?id=1089061
Merge pull request #116 from bzwei/state_machine

Replace the external state_machine with an internal implementation