updated photo management - deletion of photos when unneeded or upon cleaning the database