* few minor fixes to SQL