Large refactoring of code, introducing classes for all states, docstrings, python packaging for reuse