Slight refactoring and increase in documentation.