Changed delegate method to only get called on the main thread.