Ported from compat to core