More misc refactoring