Fix issue with waiting for the app to paint