Manually adding changes in #258 into 1.0.x.