Fixed some of the memory leaks...
There still is an increase in memory usage, but only a few leaks are left.