Merge pull request #297 from conrado/master

cherry-picked bits