sort out NULL_STREAM global variable issues