Bugfix/labels tagging

This bugfix is intended to resolve the problem mentioned in the ticket #2902 and also optimize the code. Instead of making 1 call AJAX for each object(message), only one call AJAX request is made for all the selected messages.

Another quick fix is made at the same time; there is no longer a visual glitch where the selection is wrong at the end of the AJAX call.
Isn't this part of a different pull request?