Improved SM life-cycle: fixes and improvements in view related to new SM states; unit testing; improvements in SM life cycle; refactoring