cleanup and some minor fixes