Small sql fixes.