Fix for #97 and #112