Like my earlier comment, table.units always has a length property when table.arraymode is true, so these changes should not be necessary.

lua_len sets table.length, not table.uints.length.