[IR] Minor cleanup + updates to IR flag computation.

* Added / cleaned up / re-organized some comments.
* Fixed a bug in updates to couple of flags.
* Removed some unused imports.