Migrating code to C