Added mutex lock
and some more comments