Index: /trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java	(revision 1234)
+++ /trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java	(revision 1235)
@@ -76,4 +76,8 @@
      */
     public void visit(Node n) {
+        // check, if the node is visible at all
+        Point p = nc.getPoint(n.eastNorth);
+        if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
+        
         IconElemStyle nodeStyle = (IconElemStyle)styles.get(n);
         if (nodeStyle != null && isZoomOk(nodeStyle))
@@ -95,4 +99,14 @@
             return;
 
+        // check, if the way is visible at all
+        Polygon polygon = new Polygon();
+        for (Node n : w.nodes)
+        {
+            Point p = nc.getPoint(n.eastNorth);
+            polygon.addPoint(p.x,p.y);
+        }
+        if(!isPolygonVisible(polygon))
+            return;
+        
         ElemStyle wayStyle = styles.get(w);
 
@@ -104,5 +118,4 @@
         if(wayStyle!=null)
         {
-            boolean area = false;
             if(wayStyle instanceof LineElemStyle)
                 l = (LineElemStyle)wayStyle;
@@ -111,8 +124,7 @@
                 areacolor = ((AreaElemStyle)wayStyle).color;
                 l = ((AreaElemStyle)wayStyle).line;
-                area = true;
-            }
-            if (area && fillAreas)
-                drawWayAsArea(w, areacolor);
+                if (fillAreas)
+                    drawWayAsArea(w, areacolor);
+            }
         }
 
@@ -129,4 +141,5 @@
         int realWidth = 0; //the real width of the element in meters
         boolean dashed = false;
+        Node lastN;
 
         if(l != null)
@@ -147,5 +160,5 @@
             color = selectedColor;
 
-        Node lastN;
+        // draw overlays under the way
         if(l != null && l.overlays != null)
         {
@@ -168,4 +181,5 @@
         }
 
+        // draw the way
         lastN = null;
         for(Node n : w.nodes)
@@ -176,4 +190,5 @@
         }
 
+        // draw overlays above the way
         if(l != null && l.overlays != null)
         {
@@ -799,5 +814,8 @@
         alreadyDrawnAreas = new LinkedList<Way>();
         selectedCall = false;
-
+        
+        // update the style name, just in case the user changed it in the meantime
+        styles.updateStyleName();
+        
         if(profiler) 
         {
Index: /trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 1234)
+++ /trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 1235)
@@ -9,4 +9,5 @@
 import java.awt.Graphics2D;
 import java.awt.Point;
+import java.awt.Polygon;
 import java.awt.Rectangle;
 import java.awt.RenderingHints;
@@ -357,4 +358,14 @@
     }
 
+    protected boolean isPolygonVisible(Polygon polygon) {
+        Rectangle bounds = polygon.getBounds();
+		if (bounds.x > nc.getWidth()) return false;
+		else if (bounds.y > nc.getHeight()) return false;
+		else if (bounds.x + polygon.getBounds().width < 0) return false;
+		else if (bounds.y + polygon.getBounds().height < 0) return false;
+        
+        return true;
+    }
+        
     public void setGraphics(Graphics g) {
         this.g = g;
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java	(revision 1234)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java	(revision 1235)
@@ -31,8 +31,15 @@
     }
     HashMap<String, StyleSet> styleSet;
+    String styleName;
 
     public ElemStyles()
     {
         styleSet = new HashMap<String, StyleSet>();
+        updateStyleName();
+    }
+
+    public void updateStyleName() {
+        // Main.pref.get() is slow when done thousands of times, do it once here and cache it
+        styleName = Main.pref.get("mappaint.style", "standard");
     }
 
@@ -78,5 +85,5 @@
     {
         if(name == null)
-            name = Main.pref.get("mappaint.style", "standard");
+            name = styleName;
         StyleSet s = styleSet.get(name);
         if(create && s == null)
