Backported fix from EK goupx