further cleanup + bug fixing