cleanup + possible bug fixes