Added a mutex class which is a wrapper over the pthread_mutex functionality.
Smartpointers reference counting is somewhat thread-safe now.