fix #98 #99 and half of #100