Correctly synchronize messageQueue