Patched reverted commit from @neoengtai