improved persistence functions, added logging