Resolves deadlocking issues related to thread starvation.

1. Re-architected everything to be synchronous by default and asynchronous methods are simply wrapped versions of the synchronous ones.
2. Changed TMMemoryCache to use pthread_locks instead of dispatch_queues to protect resources (this is where we lose our performance, context switching is faster than locks).
3. Added an integration test which shows the deadlocking (but passes with the above changes).