Docs, refactoring, bugfixes