Refactoring and documentation update.