hb_system_sleep: refactoring.