Possible bug fix for memory leak