Added code for waiting on barriers to return.