Split out library-scanning code.