Cleanups and optimizations.

More than one second saved on initialization.