Alert system improvements

* fix alert crash when related ap is deleted
* ensure unsent old alerts are deleted