fixing leak and deref protects