address comments; fix ref count bug