fixes for Issue 215 and Issue 221 and Issue 238

fixes for Issue #215 and Issue #221 and Issue #238 ... subsumes PR #237