merged in new sql stuff