ebuild: add _reset_legacy_globals for reload

This avoids weird issues that are triggered when the module is
reloaded (like having classes redefined while instances from the old
classes are still around, triggering TypeError confusion).