Add global tracking to the imperative phase.
Add capture generation using collected globals.