Made everything work with proper reference counting.