Removed unused code and added comments