improve sql
Merge branch 'develop' into 1.x-stable