Backport of PR #109 from 0.2 branch