Fixes #3571. Credit to @ayumihamsaki. Thanks to @petehalverson for his PR testing system, this is the first PR I'm merging after testing it with that system.