improve generate class js to use correct constructors