Refactored addConstructor to support PhoneGap 3.X