bug fixs and some changes