Fix programming mistakes and compiler warning concerning class Grid