Adjusted process function to return document node for the validate and cleanup functions.