some clean-up and reorganization