Added thread safety to ID.