Fix several SQL injection vulnerabilities