Various startup optimizations and a little dead code removal