diff --git a/Code/Mantid/docs/runsphinx.py.in b/Code/Mantid/docs/runsphinx.py.in
index 6d6c3b6e135dda4a82f70c6fb00b8ba9bad7ea3f..28f117aede4d0707543b633f0b13f3246ccfa523 100644
--- a/Code/Mantid/docs/runsphinx.py.in
+++ b/Code/Mantid/docs/runsphinx.py.in
@@ -12,10 +12,12 @@ if screenshots_dir != "":
 
 builder = "@BUILDER@"
 src_dir = "@CMAKE_CURRENT_SOURCE_DIR@/source"
-output_dir = os.path.join("@SPHINX_BUILD_DIR@", builder)
+sphinx_build_dir = "@SPHINX_BUILD_DIR@"
+output_dir = os.path.join(sphinx_build_dir, builder)
+doctree_dir = os.path.join(sphinx_build_dir, "doctrees")
 
 if __name__ == "__main__":
     from sphinx import main
-    argv = [sys.executable, "-b", builder, src_dir, output_dir]
+    argv = [sys.executable, "-b", builder, "-d", doctree_dir, src_dir, output_dir]
     sys.exit(main(argv))
 
diff --git a/Code/Mantid/docs/sphinxext/mantiddoc/directives/algorithm.py b/Code/Mantid/docs/sphinxext/mantiddoc/directives/algorithm.py
index 2a58b343f3efcea349300a57ccffcdd16e0bcc78..2be0d8c4058e80c80d4448e0d436d3073f1a2956 100644
--- a/Code/Mantid/docs/sphinxext/mantiddoc/directives/algorithm.py
+++ b/Code/Mantid/docs/sphinxext/mantiddoc/directives/algorithm.py
@@ -36,7 +36,6 @@ class AlgorithmDirective(BaseDirective):
         """
         Called by Sphinx when the ..algorithm:: directive is encountered
         """
-        self._insert_reference_link()
         self._insert_pagetitle()
         imgpath = self._create_screenshot()
         self._insert_screenshot_link(imgpath)
@@ -46,28 +45,31 @@ class AlgorithmDirective(BaseDirective):
         self.commit_rst()
         return []
 
-    def _insert_reference_link(self):
+    def _insert_pagetitle(self):
         """
         Outputs a reference to the top of the algorithm's rst
         of the form ".. _algm-AlgorithmName-vVersion:", so that
         the page can be referenced using 
         :ref:`algm-AlgorithmName-version`. If this is the highest 
-        version then it also outputs a reference ".. _algm-AlgorithmName:
+        version then it outputs a reference ".. _algm-AlgorithmName: instead
+        
+        It then outputs a title for the page
         """
         from mantid.api import AlgorithmFactory
 
         alg_name = self.algorithm_name()
         version = self.algorithm_version()
-        self.add_rst(".. _algm-%s-v%d:\n" % (alg_name, version))
 
+        # page reference must come directly before the title if it wants
+        # to be referenced without defining the link text. Here we put the
+        # specific version one first so that it always must be referenced
+        # using the full link text ":ref`LinkText <algm-AlgorithmName-vX>`:"
+        self.add_rst(".. _algm-%s-v%d:\n\n" % (alg_name, version))
         if AlgorithmFactory.highestVersion(alg_name) == version:
-            self.add_rst(".. _algm-%s:\n" % alg_name)
+            self.add_rst(".. _algm-%s:\n\n" % alg_name)
 
-    def _insert_pagetitle(self):
-        """
-        Outputs a title for the page
-        """
-        title = "%s v%d" % (self.algorithm_name(), self.algorithm_version())
+        # title
+        title = "%s v%d" % (alg_name, version)
         self.add_rst(self.make_header(title, True))
 
     def _insert_toc(self):
diff --git a/Code/Mantid/docs/sphinxext/mantiddoc/directives/base.py b/Code/Mantid/docs/sphinxext/mantiddoc/directives/base.py
index f52f4c635420bc4c8dfa4666221c1125cbd4fdfc..cad897687a4f13003aab76484e0be224c96b468a 100644
--- a/Code/Mantid/docs/sphinxext/mantiddoc/directives/base.py
+++ b/Code/Mantid/docs/sphinxext/mantiddoc/directives/base.py
@@ -96,7 +96,7 @@ class BaseDirective(Directive):
           str: ReST formatted header with algorithm_name as content.
         """
         if pagetitle:
-            line = "\n" + "=" * len(name) + "\n"
+            line = "\n" + "=" * (len(name) + 1) + "\n"
             return line + name + line
         else:
             line = "\n" + "-" * len(name) + "\n"