Refactoring the bitsd.persistence module.