Mutex/Locks and algorithm

Mutex and locks security
Algorithm implementation
Light architecture redesign