Port fix from #105 to 1.x branch.

This will fix #101 for the 1.x branch.