fix #16,#15,#11.  worked on #13