More refactoring and tweaks...