Fix template bug, other misc changes

I fixed the template bug that was reported by one of the GSoC candidates.
I have update the readme with a little bit of information about what to look out for in the code.
I have made some small changes to pull out more sql.php use.