I haven't looked at the code deeply enough recently, but I think it'd likely be better to make sure that md is never null.  ie, that the real fix is elsewhere, earlier in the parsing.