(Still have to fix uses of exec to set local variables. Will be addressed in a subsequent merge, to keep this one from getting too big.)