Added comments and deleted unused code