more improvements to sleep/wake handling