waitUntilFinished debugged, needs refactoring.
Refactored (with debug noise).
Refactored and cleaned up.