* Make smartSleep send heartbeat before sleeping
Sending the heartbeat (and waiting) after waking up would delay
processing inputs. For example, a switch could be back to the
open state before the wait is over.
* Fix typos in comments in smartSleep methods