Import as develop

Rebased PR #981 on to develop. Required a few conflicts resolved.

Would be great to have a repeat of the testing done on the previous PR to ensure conflicts that were resolved have not lost functionality.