Removing debug output
Writing docstrings for the script

Documenting how each function works, with a bit of cleanup to make each
function follow some conventions based on the docstrings.