stripped down extensively, but fixed problems

The modules imported from a locally-imported module will
now also be removed from sys.modules.