fix for #127 and #146