Correctly compute imports closure and improve handling of external URLs.

Change-Id: Ib477cab63bb4a519a5ac8eed093fe1697f75f2a3