Hopefully fixes #2039. Thanks to helios for investigating!