Fix for #126 and #116