Delete unnecessary code, fix some SQL injection issues