Bug 944087. Fix main thread unlocking and tidy up. r=Bas