Ported code.