refs: split filesystem-based refs code into a new file