Code reformatting
Fixed a race condition issue
Fixed multiple instance crashing