Fixes#188 by saving instance state and restore it properly.