Few more tweaks to the app initialization process.

Also add some extra sanity checks