Fixes for #221, #222 and #223