Lint & Cleanup of legend-code