Some debug info, plus a bug fix