Improve end of alarm handling and other fixes