handle correctly sleep functions, and add some other stuff