more changes to SQL, more tables, handling indices