sleep.c all functionalities bulked out and minimally tested