some fixes and clean up