wait() bug

Simplify the time calculations keeping the units in seconds.

Switch to usleep() because sleep(0.1) doesn't work as expected, i.e., sleep() expects the number of seconds as an integer.