Would be cool to make this logic generic across other session methods like `merge`, `flush` etc.