only fetch lib if necessary + better cleanup