remove dead code

Replaces #5835.