Fixed distinct call in TicketSearch() to not use other fields than id.
This could cause duplicate entries if fields of joined tables were in the select clause.