Fixed: $patterns was not actually being passed to wait().