improved memory management (crash if the user have a lot images saved)