pord_weakdom rewritten in C