Fixed error checking on sleep and implemented usleep