Mutliple tweaks and fixes to startup code