Added a bunch of debuging function. TEST broken for the moment.