Fixed some bugs for #26.