Add docstring. Remove unused os import. Clean up PEP8 issues.