Misc refactors