Improve null handling when adding custom header