Fixed library observer bug and refactored library queries