Bug fixing for #119 and #120.