Docs, refactoring and cleaning