Refactored startup code