Possible resource leak fix