remove dead lines and tidy