Fixes #226: atomic operations and transaction support in AR.

Reworked version of #244.
Fixes #226.
See also #233.