Imported resources improvements

Fix bugs with imported resources.
Rewrote scope tracking system : it is now possible to know the original
host of an imported resource.