Fix problem where referenced to declarations weren't being resolved properly.
They were being overwritten with NULL when looking for references to definitions.