Bug Fixes. Added mutexes