Rewrite
Fix tests
Update dependencies