Some refactoring of the waitForActivity methods