After most of the functions have been killed, refactor the ones that are left into something not ugly.