Fixed #153, with a regression test.