Modified sleeping code.