Added comments and removed dead code