Fixed legend location and plot generation. Fogot to call plt.close() after saving the figs