Fixed bugs where database queries crash when names contain punctuation