Fix attach internal node function.

The old internal node function was breaking because it declared **arr and **old and
dereferenced them before it allocated space. Working with this there were a lot more
little problems and it was written kind of confusing so I've tried to simplify it a
while keeping the same functionality. There was also a memory leak caused by not
releasing the internal node's children when it was released.

Rename current node to parent node in attach internal node.
Merge pull request #199 from RickEyre/attach-internal-node-fix

Fix attach attach internal node function.