some more sql fixes