Fixed #3055 Correctly detect db_version; fixed gateway setting rewriting
Merge branch 'issue/3055'