Remove a lot of dead code and unused imports