More compilation fixes and dead code removal