Fixed some issues with UI thread operations