Fix crashes and errors relating to missing targets.