first pass at migrating all the util functions in util.c