Added output stream flushing where necessary