Fixing the wait flag issue.