Remove dead code and fix tdb2