Factored out setup code