Various fixes

Removing a lot of global state, the code should be more testable this way.
Also renamed the module file to secretary, this way it's easier to make a package out of it and subimt to pypi