Add static ctor support, fix a NRE bug