Fixes #237

This is a new pull request.

The pull request does not contain a test suite because I do not know how to repair them better.