Tons of dead code

THis one is an absolute monster. Removes a lot of dead code / code paths. several minor fixes as well.