fix #20, fix #15, fix #14, fix #11, fix #9