Added grid. Various bug-fixes