Removed unused functions; added a few more comments