Improved headers handling