remove dead code and some other fixes