minor sql improvements
resolve conflict