Fixed wait group bug with panic handling that was causing a hang