fix async reference issues

Some issues with loops and async references.