Fixes for issue 39