Fixed several problems with output thread.