remove unused local vars

And some other changes