Further refactoring and documentation updates