Complete refactoring of neighborhood_arrfunc