Several bugs, which together fix #246.  See the comment in the new regression test for details.