defringe: moved xy_avg etc. declarations up over the first goto, add (size_t) typecast in all in[..] and out[..] accesses