Some fixes and dead code elimination