added updated state machine and integral, also built the observer class (untested)