Fix merging of headers

Moving everything into a single block caused the user-provided headers to
overwrite the merged headers.