Stream header improvements
Improved global variables definition and buffer management