more clean up and bug fixes