Fix bugs #13 #17