Fix for #151 and #148