cleanup + simplify + fix tests