cleaned up docstrings and reorganized functions.  slight code cleanup as well.