Refactoring and documentation updates