Fixed bug where the app could deadlock if performBlockOnMainThread was called while already on the main thread.