Migrated reftools c code to Python reftools.