Changed calls to usleep() to nanosleep(). usleep is deprecated and
not sleeping on some platforms