major clean-up of old code