Made type conversion more efficient by calling C functions