Proper fix for memory leak

Removed all auto release pools and replaced with STL containers.
Removed all @synchronized keywords and replaced with pthread mutexes.

This will also improve performance.