Added locking to unique code generation so that duplicate keys cannot be created.