debug output, some fixes