Fixes memory leak