Small sql changes