add some fences and fix the wait/signal code a bit

Signed-off-by: Sébastien Boisvert <boisvert@anl.gov>