Add docstrings; rename functions for readability.