added stream listeners and a flush handler