Made header buffer dynamically allocated