Alert handling method changed to prevent NPEs.