Improved map drawing code