Fixed a bug with stream clearing