Rewrite append_to_manynodes to use realloc

Previously it allocated a many_nodes instance one size larger, copied
everything over and added the new one to the end. This realloc based one
should be much more efficient.