Rewrite waiting list code
Use static_cast instead of C casts