More fixes and merge sql delete