Adding docstrings, removing a global variable that didn't need to be declared, and adding commenting