Fix error in email view and add regex to clean up search queries