Use safe name when performing resource lookups

Also should return nullptr if no resource found. Tests needed.