some improvements and clean up