Refactoring and more comments