Misc refactor