Cleaned a little bit some parts of the code in grid.py