Added much better Sphinx compatible code documentation, added a few more tests, and refactored some minor things