Merge pull request #271 from bensemmler/fixes

Merge fixes for #1787, #1781, #1779.