Fix a bug with child package, improve support for foreign package