organised files better, added docstrings, re-ordered code, added some new functions