Hand merge of pull request #222 and issue #220