fix segfault due to unregister after free

Also fixed a leak in nm_init where alternate return paths did not unregister
values.

This commit no longer segfaults on the memory testing code.

Still need to convert yale and list storage.

Also need to do performance checks to see if this new scheme has slowed down
the code.