Ported to C