Fix filter escaping, closes #316, closes #320