Applied the PR upstream. Thanks Louis Jacomet, Alex Snaps, Radim Vansa and everyone else for helping with this!