Reorganized code to make the execution flow clearer
Added async() and wait() pragma clauses. No noticeable improvement.