Revert "Refactor find_library code"

This reverts commit d246c2d01aec45dbbb16045d1bf31c922451eaf2.