Fix various bugs in plot.