Some more refactoring and tinkering