Fixed hang when starting with multiple startup tabs.
Fixes for various compiler and static analysis warnings