Bugfixes in the plot function