Massive clean up of old code