remove unused code: vars, foreach keys, etc
Fixes #5052 using name for annotations and using correct class for export