Moved game logic code off the main UI thread to improve performance.