Fixed null pointer exceptions in stream class.