Fix uninitialized table issue.
Get rid of table handling that is never used and breaks non-table usage.
Change the legend command to be dynamic