Various refactors to clean up redundancy