Added some docstrings and improved global variable naming