Rewriting part of the aritmethic logic. Fixing bugs.