Fix for #1242
Initial commit to fix #1207