Factor out setup code that always needs to get called.