fixes #1483 and #1380 thanks to the patch from @jimmidyson - many thanks!
removed cruft