Gh 1071

this is tested and ready for merge.