some clean-up and debug