Fix for #126 and #127