Clean up some utility code