refactoring and docs.