[gh-607] Closes #315
This is the big one that needs testing. (This includes issue-604 (#604) already merged so look at that pull request first.) #315
issue