state refactoring

implemented abstract class for states. generation
of states is now done via a factory class.
Merge remote-tracking branch 'origin/master'