Added lines to handle cases where objectFactories parameters are DOM objects