Consolidate functions and run them early