Added debug mode with more verbose description of errors.