Added some more debuging code

It can de activated by defining DEBUG at the beginning of the code.