Add debug option and fix access denided problem