Refactoring rendering to only write the parts of the screen that have changed

Two other places in this file, too.