Added `modifyAndGet` helper function.
Thanks to Nikita Volkov.