Revert "Merge of Rich T-W's changes"

This reverts commit 90d25bf648564a3f1639da3a3e79f6110bec9fed.
Re-apply Rich's patch, now with line-endings fixed