fix removing unreferenced variables