Minor refactoring of run code.