Moved two common functions to util.go.