Incorporated internal use of sphelpers.ensureSPLibraryLoaded() function and others.