v2 complete rewrite