Added some comments and removed unused code