Adding docstrings explaining how everything works.