More rearrangement of the code. Refactoring nearly complete but eyes getting tired.