cleanup + bug fixes