some last minute changes + new sql