fix 3 major bugs and debug info.