Reformat.
Removed two newlines
Fixed some race conditions and a crash