Removes unwanted referemces.