Fixed vast amounts of memory leaks, rewritten stream library to avoid having to deal directly with lengths and memory allocations (user is only responsible for freeing of the data). Protected throughout against failed malloc()s.
Updated stream.c