Coverity bugfix (missing NULL check) and ref counting errors. (on module constants, so not really leaking, just not good.)