Improve errors handling.

In some cases it could be up to 3 alert boxes displayed.
Now it should be only one.
End activity on errors