Fix issue with filtering by deleted templates