More subtle refactoring of persistance code