Fixed possible race condition
oops! You can't do a mutex lock on a nil variable, unsurprisingly, so previously this was innefective at preventing the possible race condition (I've never seen it though).