Commented things and added docstrings.