Fix for issues #161 and #162.