fixes for Issue 215 and Issue 221

merge fixes for Issue 215 and Issue 221 into master