Some refactoring/commenting