Code refactoring and bug fixes.

Fixes and refactoring in main.c, mempool.c, compare.c, filter.[ch],
group.c, groupnode.[ch], hash.c, node.[ch], sort.[ch], traverse.c
test_sort.c added.
test_node.c added.
test_groupnode.c added.
test_filter.c added.
test_group.c added.
test_mempool.c added.