Merge three separate "fetch refs" functions