Slove problem with fitting.(Issue #5). Add a lot of debuging stuff into the code.