fixes issue #1037
fixes issue #1035
fixes issue #895
update issue #1035 with tests