Fixed memory leak from a MemoryStream that wasn't closing.