Remove unused and not completely correct code

This stuff wasn't tested (EDIT: with the same tests as the rest of the system) and has diverged from reality, so it's time for it to go away.
What are we testing here? Also the vars are missing in the Errorf