added logging and backup/cleanup