Fixed segfault that occurs inside add_chain() due to incorrect initialization of nodes using malloc.  Now it uses the new operator and works fine.