Fixed possible resource leak