Added docstrings, changed some variable names.