refactoring, lib_history moved to PDO (except inserts)