Fixes for #15, #18 and #19