Some optimisation and fixes; fixes have been used for last transfer function commits already.
Small fix.
Add legends to plots.