Moved StateModel into perpetuality scope and small refactorings