[#3837] Fixes thanks to stof and WouterJ