Fixed initialization order bug with statics

Fixes a crash due to destructor order.