Fix broken artifacgt caching for codegen.

Added a bunch of clarifying comments in the code
to prevent future regression.

Auditors: pl