Fixes for functions that require DomDocument.

DomDocument wasn't being called in the correct scope.