free(e.name) should probably be encapsulated
misc cleanups