Clean up and remove dead code