Rebuilding code to make it easier to debug. Should be optimized later.
Created working inverse shiftrows.