Discard VarDefs that are not actually used.
Discard side-effect-free LoadModules if not used.
Merge pull request #840 from sjrd/discard-useless-things

Discard useless things