Minor refactoring + gofmt