Silenced "used only once" warnings
Fixed some SQL syntax errors