Restart

Add support for $restart, and fix some tests.