Small fixes to prevent errors when using very small grid sizes