Various cleanup of code

Making it more configurable, from the chart.json
Various simplification of code, still much to do.