Added lots of debugging code