Pulling out some common persistence code.