More code cleanup

Most of this code will eventually be totally replaced, but I can't bear to look at it like this