Fix rendering glitches when far from the center of the map

Fixes #1093 and #228