fix for #1012, #1013, fix JBM flush output buffer, use also the global output buffer instead of a local one.