Refactoring and inline documentation