fix memory leak while constructing rings