Reorganized code and comments

Added some comments and deleted some lines.