Bug fix

Fixed a bug where certain SQL queries weren't being properly escaped.