Some minor refactoring of methods and documentation