I need another set of eyes to look at this and tell me why it digs incorrectly.

If I knew how to output my "debug" lines to a file I could maybe watch the numbers go by easier.
I've made so many chenges I'm losing track. I even had it set up to do two rows at once and it worked fairly well but I removed it in trying to fix this. I'm trying to do this the smart and 'small file' way, I'm sure I could just put the whole thing with one command at a time, but that would be lame.
If there's a command I'm not aware of please point it out. I know there's a lot of stuff in LUA I don't know.

Spoiler

term.clear()
term.setCursorPos(1,1)
-- set defaults    
local unloaded = 0
local collected = 0
local YES = ("y")
local xPos,zPos = 0,0                --Position
local xDir,zDir = 0,1                --Direction
local AF = turtle.getFuelLevel()    --Available Fuel


--Command Line based arguements
local tArgs = {...}
hwH,hwW,hwD = tArgs[1], tArgs[2], tArgs[3]
hwW = tonumber(hwW)
hwH = tonumber(hwH)
hwD = tonumber(hwD)

if #tArgs ~= 3 then
  print ("Invalid number of arguments.")
  print("Hallway # # #")
  print("<Height> <Width> <Depth>")
  sleep (2)
  print ("That's ok, we can do it now.")
  sleep (2)
term.clear()
term.setCursorPos(1,1)


-- Size Check if no Command Line args
print ("I'll need the measurements of your hallway.")
print ("(Remember to place your turtle facing the block of the Bottom-hwLeft corner)")
repeat
   write ("How TALL? ")
	 hwH = tonumber(read())
	    if hwH < 1 then
		  write ("Must be a number! How TALL? ")
		  hwH = tonumber(read())
	    end
   write ("How WIDE? ")
	 hwW = tonumber(read())
	    if hwW < 1 then
		  write ("Must be a number! How WIDE? ")
		  hwW = tonumber(read())
	    end
   write ("How LONG? ")
	 hwD = tonumber(read())
	    if hwD < 1 then
		  write ("Must be a number! How LONG? ")
		  hwD = tonumber(read())
	    end
  print ("Ok. I'll make it " .. hwH .. " tall and " .. hwW .. " wide and " .. hwD .. " long.")
  write ("Is this ok? [y/n] ")
  local Correct = read()
until Correct == YES
else
  print ("Assuming you know what you are doing.")
  write ("I'll make it " .. hwH .. " tall and " .. hwW .. " wide and " .. hwD .. " long.")
  sleep (2)
end  

--        Have Enough Fuel
--        TF = Total Fuel            This will need to be changed based on movement of Turtle.
    local TM = hwH*hwD*hwW        -- Total Movement
    local CC = TM/80                -- Charcoal needed
if CC > TM then
    print ("Total blocks mined will be " .. TF .. " which will use " .. CC .." charcoal.")
    write ("Would you like to refuel now? [y/n] ") local RF = read()
        if RF == YES then
            if turtle.getFuelLevel() ~= "unlimited" then
                for n=1,16 do
                    local nCount = turtle.getItemCount(n)
                    if nCount > 0 then
                            turtle.select( n )
                            if nCount >= nLimit then
                                    if turtle.refuel( nLimit ) then
                                    break
                                    end
                            end
                    else
                    if turtle.refuel( nCount ) then
                    nLimit = nLimit - nCount
                    end
                end
            end
        end


print( "Fuel level is "..turtle.getFuelLevel() )





else
    term.clear()
    term.setCursorPos(1,1)
    print ("Fueled up and ready to roll!")
    sleep (2)
end


--		   Starting Timer
term.clear()
term.setCursorPos(1,1)
print ("I'll get started in a few seconds.")
print ()
print ("If you've made a mistake hold CTRL+T to HAULT program.")
sleep (6)
end

--        amount collected display

local function collect()
    collected = collected + 1
    if math.fmod(collected, 16) == 0 then
        print( "Mined "..collected.." items." )
    end
end

--       LOCAL DIG FUNCTIONS

local function DigF()
    while turtle.detect() do
        if turtle.dig() then
            collect()
            else
            return false
        end
    end
    return true
end

local function DigU()
    while turtle.detectUp() do
        if turtle.digUp() then
            collect()
        else
            return false
        end
    end
    return true
end

local function DigD()
    while turtle.detectDown() do
        if turtle.digDown() then
            collect()
            else
            return false
        end
    end
    return true
end

local function DigL()
    turtle.turnLeft()
    while turtle.detect() do
        if turtle.dig() then
            collect()
        else
            return false
        end
    end
    turtle.turnRight()
    return true
end

local function DigR()
    turtle.turnRight()
    while turtle.detect() do
        if turtle.dig() then
            collect()
        else
            return false
        end
    end
    turtle.turnLeft()
    return true
end


--              Fuel functions
local function refuel()
    local fuelLevel = turtle.getFuelLevel()
    if fuelLevel == "unlimited" or fuelLevel > 0 then
        return
    end
    
    local function tryRefuel()
        for n=1,16 do
            if turtle.getItemCount(n) > 0 then
                turtle.select(n)
                if turtle.refuel(1) then
                    turtle.select(1)
                    return true
                end
            end
        end
        turtle.select(1)
        return false
    end
    
    if not tryRefuel() then
        print( "Add more fuel to continue." )
        while not tryRefuel() do
            sleep(1.5)
        end
        print( "Resuming Tunnel." )
    end
end



--             MOVEMENT FUNCTIONS


local function MU()    -- Move hwUp
    while not turtle.up() do
        if turtle.detectUp() then
            if not DigU() then
                return false
            end
        elseif turtle.attackUp() then
            collect()
        else
        end
    end
    return true
end

local function MD()    -- Move hwDown
    while not turtle.down() do
        if turtle.detectDown() then
            if not DigD() then
                return false
            end
        elseif turtle.attackDown() then
            collect()
        else
        end
    end
    return true
end

local function MF()    -- Move Forward
    while not turtle.forward() do
        if turtle.detect() then
            if not DigF() then
                return false
            end
        elseif turtle.attack() then
            collect()
        else
        end
    end
    return true
end

print( "Constructing..." )

hwRight,hwLeft,hwUp,hwDown = (hwW),0,(hwH),0

print ("R" .. hwRight .." L" .. hwLeft .." U" .. hwUp .." D" .. hwDown .."    W" .. hwW .." H" .. hwH .." D" .. hwD .."")

--            Dig then move forward and turn right into starting position
repeat                                --        Move forward
    refuel()
    MF()
    sleep(0.3)
    turtle.turnRight()
    hwD = hwD - 1
    repeat                            --        Keep moving back and forth until all the way up
        repeat                        --        Dig to right
            hwRight = hwRight - 1
            hwLeft = hwLeft + 1
            MF()
            sleep(0.3)
        until hwRight == 1

        turtle.turnLeft()            --        Turn Around p1

        if hwUp > 1 then            --        Move up if needed
            MU()
            sleep(0.3)
            hwUp = hwUp - 1
            hwDown = hwDown + 1
        end
        refuel()
        turtle.turnLeft()            --        Turn Around p2

        repeat                        --        Dig to left
            hwLeft = hwLeft - 1
            hwRight = hwRight + 1
            MF()
            sleep(0.3)
        until  hwLeft == 1
    until hwUp == 1    
    repeat
        hwDown = hwDown - 1
        hwUp = hwUp + 1
        MD()
        sleep(0.3)
    until hwDown == 0
    turtle.turnRight()                --        Turn to start position for next row
until hwD < 1

print( "Tunnel complete." )
print( "Mined "..collected.." items total." )