Add some screen-off code from ktoonsez code and some ondemand adjustments from wanam.