Improving comments and reordering some XML functions