Remove unsafe and atomic stuffs. Replaced by mutex lock.