Problems with already send headers fix

with repect to issue Problems with already send headers