Thanks mitsuhiko for the report. Backport of 65b6eff3 and adaptation of 8aaca65 from master.
65b6eff3
8aaca65