quite some fixes to the alarm scheduler. Still not the most beautiful code, but at least it works correctly now.