Fix some reference leaks.