fix issue with propagating wrong library name, unroll recursion

@wjwwood Please review.