Move `copyHeaders` as it's used all over the place