Fixed attributes parameter in createWith and initializeWith callbacks to contain only factory defined attributes. Refactored and reorganized code