tweak library search logic. Fix #1 Fix #2