Replace custom waiting code with a WaitGroup

Signed-off-by: Ian Calvert <ianjcalvert@gmail.com>