Added additional documentation

Added comments above certain functions and subfunctions to clarify their
meaning in life.