Santak bugs fix

all the bugs reported by santak are fixed