Ported cf38168af0c1b5021372ad7b1b64740040618c1a from OMP