Backport #223 to 0.7.x