Update with changes done on the development branch.

This commits backports changes done and discussed
in pull request #1223  (for the master branch).