Improve a method and remove dead code