minor sql corrections