implement debug output; fix orientation of debug output