Trying to make it more idiomatically Swift instead of clinging to C.