Add startup code, minor reorg