Refactor of application startup