bug fix - (too) early closing of headers