Refactoring and fixing documentation.