Fixed a nasty race condition on enabling/disabling alarms (thanks to ucolesanti for reporting the bug)