Path handling fixes. Encoding fixes. More debug logging.