Refactor application startup and scene building.