Clean up some util functions