Fix for getNextState in CAutomatImpl + small refactoring