Added better debug flags
Reset aggdata after writing