Backport #202 to 0.9.x, fixes #279