Sql refactoring
Merge branch 'SQL_refactoring' into develop