Tidied up grid implementation