more refactoring in prep for a better cors story!