Fixed garbage collection issues