Added some locking mechanisms. Untested.