persistence improvements and helper class to avoid code duplication