fix#3, fix #5, fix #6, fix #8