Refactoring persistence related code to use repository pattern

A few commits of relatively straight-forward code cleanup before finally deciding to use a very basic implementation of a repository pattern to allow for more code reuse for accessing the different data files.