fix some little problem; add pretty debug output