Much better stream reading code.