more sql fixes