add Makefile; fix issues with read/write to nodes
Makefile generated through gmakemake.
there are still issues with memory allocation/leaks.