Refactor library finding logic into a resusable module.