fix compatibility and performance for ctor
fix bug
if-> if else
Merge pull request #1748 from joshuastray/develop-3.0

fix compatibility and performance for ctor