Fixes the memory leaks.
On to string and iostream.