Few bug fixes to sleep timer function