Converted remaining SQL to use prepared queries