Some refactoring to please HLint