Fix problem in releasing ressources