Merge "Wait for threads to finish before returning." into oc-dev