more improvements for regression and code clean up