Rewrite
Fix tests