Fixes for #195 to #222 and #226 to #232