Refactoring and improving the documentation