Added state stack class
Updated commenting