Reformat file. Minor refactoring