Fix for #152 and #150.