Removes unused references from code