Refactor #4365 Refactor constructors to avoid JSB issues of extending essential classes