- changed some mutexes to recursive_mutex
- some refactoring
- added some comments