Minor refactoring etc.