better factoring of savepoint handling (alternative version)

This is an alternative to #150 (if one is merged, the other should be thrown away)