Fix bug 3: Thread Cleanup
Fix Bug 4: Memory State