Move helper function from strbuf to ref-filter. Get rid of some memory leaks. Thanks to everyone! Olga