Fixed typos.
Added thread safety.