fix #8, fix #11, fix #14