Removed unused definitions, added comments, etc