Replace custom sleep() routines with C++11 std::this_thread::sleep_for().