Refactoring. Mostly shuffling stuff around.