Improved comments and cleaned up code to for comprehension.