Fixed remaining SQL issues.