Finish refactoring (rewrite __sub_array as a C function)