Cleanup in main player loop code