Added lock for received messages

TODO : test if the bug was fixed