fixes for headers on error