Another round of SQL fixes
Even more updates to sql to avoid injection attacks
Another batch of SQL replaced
Finally compiles