Some memory managment
It still crashes, but logically it's better