Refactor: more refactoring and docs