Forgot about templates
Fixed some bad sql
Merge remote-tracking branch 'origin/master'