Avoiding several memory leaks in Grid.