Removed unused code, added comments