Re-arranged startup code (in progress)