Fixed variable reference and validation check for document root.