big unreferenced variable cleanup