Move all external references to lib