Refactorings in GenBCode, remove Tracked

Note 1: the first bunch of commits in this PR (the ones from June 22) is being reviewed in a separate PR (#3826), ignore them here.

Note 2: the commits marked [squash-after-review] don't build (except for the last). They exist to make reviewing easier, I'll squash them into one before merging.

For the big commit ("Remove Tracked, ..."), I'll add some comments to the diff on GitHub.

Review by @gkossakowski