Fix runtime null pointer exceptions for security functions