minor sql corrections.