re-add xpcom shutdown handler. style changes and tidy up constants