refactored search/loadLibrary methods and some other refactorings