Fix a few bugs in atomic modification