fix #7, fix #8, fix #9