Fixed some bugs with alarm manager.