preferences refactoring
fix library
fix query test