more cleanup + bug fixes