Fixed bug with incorrect Entities, and added support for filtration by db query.