Added comments and removed unused functions