Fix library resolving and build environment leakage.