Fix for #157 & #139