fixes to SQL scripts