Move str_func to util, code cleanup