Merge of pull request 424 with some changes