Application setup code refactoring