Small refactoring, added comments