Removes unused references.