Make filtering the library more robust