Simplify readAlerts() function.

I've simplified readAlerts() function to make it more clear and understandable. Now it only recognize alert type and call appropriate alert handler.