Further rewrites to fix failing tests