simplify and unify handling of externals