Added comments and removed unnecessary code.