diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index b201052493a7b1ca01afe6787faac374a2b866d0..72846fb491bb3c1e713b5ea264e50a21c23e9dec 100644
--- a/render_povray/__init__.py
+++ b/render_povray/__init__.py
@@ -45,7 +45,6 @@ else:
     from render_povray import ui
 
 
-
 def register():
     bpy.utils.register_module(__name__)
 
@@ -252,7 +251,6 @@ def register():
 
     #############################MATERIAL######################################
 
-
     Mat.pov_irid_enable = BoolProperty(
             name="Enable Iridescence",
             description="Newton's thin film interference (like an oil slick on a puddle of water or the rainbow hues of a soap bubble.)",
@@ -339,28 +337,27 @@ def register():
             default="1")
     ##################################CustomPOV Code############################
     Mat.pov_replacement_text = StringProperty(
-            name = "Declared name:",
+            name="Declared name:",
             description="Type the declared name in custom POV code or an external .inc it points at. texture {} expected",
             default="")
 
-    #Only DUMMIES below for now: 
+    #Only DUMMIES below for now:
     Tex.pov_replacement_text = StringProperty(
-            name = "Declared name:",
+            name="Declared name:",
             description="Type the declared name in custom POV code or an external .inc it points at. pigment {} expected",
             default="")
 
     Obj.pov_replacement_text = StringProperty(
-            name = "Declared name:",
+            name="Declared name:",
             description="Type the declared name in custom POV code or an external .inc it points at. Any POV shape expected e.g: isosurface {}",
             default="")
 
     Cam.pov_replacement_text = StringProperty(
-            name = "Texts in blend file",
+            name="Texts in blend file",
             description="Type the declared name in custom POV code or an external .inc it points at. camera {} expected",
             default="")
     ##############################TEXTURE######################################
 
-
     #Custom texture gamma
     Tex.pov_tex_gamma_enable = BoolProperty(
             name="Enable custom texture gamma",
@@ -374,7 +371,6 @@ def register():
 
     #################################OBJECT####################################
 
-
     #Importance sampling
     Obj.pov_importance_value = FloatProperty(
             name="Radiosity Importance",
@@ -424,7 +420,6 @@ def register():
 
     ###################################TEXT####################################
 
-
     Text.pov_custom_code = BoolProperty(
             name="Custom Code",
             description="Add this text at the top of the exported POV-Ray file",
@@ -514,7 +509,7 @@ def unregister():
     del Cam.pov_dof_variance  # MR
     del Cam.pov_dof_confidence  # MR
     del Cam.pov_replacement_text  # MR
-    del Text.pov_custom_code  #MR
-    
+    del Text.pov_custom_code  # MR
+
 if __name__ == "__main__":
     register()
diff --git a/render_povray/render.py b/render_povray/render.py
index f0eb3bf9fc91e48c1976fbf485c0059607eb2d80..9e6176d7f8a19ee63f7d2d566d9dcdd09b30d8b2 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -198,6 +198,7 @@ def safety(name, Level):
 
 tabLevel = 0
 
+
 def write_pov(filename, scene=None, info_callback=None):
     import mathutils
     #file = filename
@@ -957,7 +958,7 @@ def write_pov(filename, scene=None, info_callback=None):
                                 t_alpha = t
 
                 ##############################################################################################################
-                    
+
                 if material.pov_replacement_text != "":
                     file.write("\n")
                     file.write(" texture{%s}\n" % material.pov_replacement_text)
@@ -1465,12 +1466,13 @@ def write_pov(filename, scene=None, info_callback=None):
         tabWrite("}\n")
 
     def exportCustomCode():
-        
-        for Text in bpy.data.texts:
-            if Text.pov_custom_code:
-                file.write("\n" + Text.as_string())
-                file.write("\n")
 
+        for txt in bpy.data.texts:
+            if txt.pov_custom_code:
+                # Why are the newlines needed?
+                file.write("\n")
+                file.write(txt.as_string())
+                file.write("\n")
 
     sel = scene.objects
     comments = scene.pov_comments_enable
@@ -1481,7 +1483,7 @@ def write_pov(filename, scene=None, info_callback=None):
     if not scene.pov_tempfiles_enable and comments:
         file.write("\n//--CUSTOM CODE--\n\n")
     exportCustomCode()
-        
+
     if not scene.pov_tempfiles_enable and comments:
         file.write("\n//--Global settings and background--\n\n")
 
diff --git a/render_povray/ui.py b/render_povray/ui.py
index 65b7e885c6ae3013d24d0e2d50b4476cf0cabe02..7619d2b255fbf6a3b933fd2b2842eb79d91d1053 100644
--- a/render_povray/ui.py
+++ b/render_povray/ui.py
@@ -508,7 +508,7 @@ class MATERIAL_PT_povray_caustics(MaterialButtonsPanel, bpy.types.Panel):
 
 class MATERIAL_PT_povray_replacement_text(MaterialButtonsPanel, bpy.types.Panel):
     bl_label = "Custom POV Code"
-    COMPAT_ENGINES = {'POVRAY_RENDER'} 
+    COMPAT_ENGINES = {'POVRAY_RENDER'}
 
     def draw(self, context):
         layout = self.layout
@@ -540,7 +540,7 @@ class TEXTURE_PT_povray_tex_gamma(TextureButtonsPanel, bpy.types.Panel):
 
 class TEXTURE_PT_povray_replacement_text(TextureButtonsPanel, bpy.types.Panel):
     bl_label = "Custom POV Code"
-    COMPAT_ENGINES = {'POVRAY_RENDER'} 
+    COMPAT_ENGINES = {'POVRAY_RENDER'}
 
     def draw(self, context):
         layout = self.layout
@@ -569,9 +569,10 @@ class OBJECT_PT_povray_obj_importance(ObjectButtonsPanel, bpy.types.Panel):
         col.label(text="Photons:")
         col.prop(obj, "pov_collect_photons", text="Receive Photon Caustics")
 
+
 class OBJECT_PT_povray_replacement_text(ObjectButtonsPanel, bpy.types.Panel):
     bl_label = "Custom POV Code"
-    COMPAT_ENGINES = {'POVRAY_RENDER'} 
+    COMPAT_ENGINES = {'POVRAY_RENDER'}
 
     def draw(self, context):
         layout = self.layout
@@ -602,7 +603,7 @@ class CAMERA_PT_povray_cam_dof(CameraDataButtonsPanel, bpy.types.Panel):
         layout.prop(cam, "pov_dof_aperture")
 
         split = layout.split()
-        
+
         col = split.column()
         col.prop(cam, "pov_dof_samples_min")
         col.prop(cam, "pov_dof_variance")
@@ -614,7 +615,7 @@ class CAMERA_PT_povray_cam_dof(CameraDataButtonsPanel, bpy.types.Panel):
 
 class CAMERA_PT_povray_replacement_text(CameraDataButtonsPanel, bpy.types.Panel):
     bl_label = "Custom POV Code"
-    COMPAT_ENGINES = {'POVRAY_RENDER'} 
+    COMPAT_ENGINES = {'POVRAY_RENDER'}
 
     def draw(self, context):
         layout = self.layout
@@ -628,7 +629,7 @@ class CAMERA_PT_povray_replacement_text(CameraDataButtonsPanel, bpy.types.Panel)
 
 class TEXT_PT_povray_custom_code(TextButtonsPanel, bpy.types.Panel):
     bl_label = "P.O.V-Ray"
-    COMPAT_ENGINES = {'POVRAY_RENDER'} 
+    COMPAT_ENGINES = {'POVRAY_RENDER'}
 
     def draw(self, context):
         layout = self.layout
@@ -636,7 +637,3 @@ class TEXT_PT_povray_custom_code(TextButtonsPanel, bpy.types.Panel):
         text = context.space_data.text
         if text:
             layout.prop(text, "pov_custom_code", text="Add as POV code")
-
-
-
-