Fix dispose logic