Fix for #163 and #162