Small refactor in alert/awake code