Fix issues #2,#5,#6 reported at github