fix regression and clean dead code