Refactoring and additional comments