Small refactoring fixes