Improved readability

Added comments and cleaned up formatting