fixes leaky references