Refactored out more for feature flags

Refactored more for feature flags