Trigger full GC from CodeManager to fix memory use

Just read the commit message. It should be enough to understand the issue.

Also, this pull request contains two other clean-up commits.

Closes #2224.