Final refactoring and documentation revision