Fix errors in ported code, on the path to happiness