diff --git a/README.rst b/README.rst
index 947c2d4b01370e4095c35a70588d9cbdb3f1d9d7..c92f28f30fcbe3e2bb54bb68e8e57f6f4d9274e5 100644
--- a/README.rst
+++ b/README.rst
@@ -141,6 +141,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 Change history
 --------------
 
+Version 2.28d (10/25/2017)
+
+- Fix for incorrect resolution of type for a child element type
+  defined with <xs:element ref="Abc"/>.  The ref= can refer to a
+  global (top level) xs:element rather than an xs:complexType, in
+  which case we need to use the type= to determine the
+  xs:complexType.  Thanks to Bob Barcklay and Olof Kindgren for
+  reporting this issue and for working with me on this and helping
+  to track down the fix.
+
 Version 2.28c (10/17/2017)
 
 - Fix for generation of GDSClassesMapping dictionary.  Formerly, we
diff --git a/django/gends_generate_django.py b/django/gends_generate_django.py
index 28e7913366029ccbb8612ba552893de296cf4dcc..056f6d09269dc0943a66751f29172af8dbd21bf4 100755
--- a/django/gends_generate_django.py
+++ b/django/gends_generate_django.py
@@ -69,6 +69,14 @@ class Writer(object):
 #
 
 def generate_model(options, module_name):
+
+    if options.class_suffixes:
+        model_suffix = '_model'
+        form_suffix = '_form'
+    else:
+        model_suffix = ''
+        form_suffix = ''
+
     global supermod
     try:
         import generatedssuper
@@ -122,14 +130,14 @@ def generate_model(options, module_name):
     for class_name in supermod.__all__:
         class_name = unique_name_map.get(class_name)
         if first_time:
-            wrtadmin('    %s_model' % (class_name, ))
+            wrtadmin('    %s%s' % (class_name, model_suffix ))
             first_time = False
         else:
-            wrtadmin(', \\\n    %s_model' % (class_name, ))
+            wrtadmin(', \\\n    %s%s' % (class_name, model_suffix ))
     wrtadmin('\n\n')
     for class_name in supermod.__all__:
         class_name = unique_name_map.get(class_name)
-        wrtadmin('admin.site.register(%s_model)\n' % (class_name, ))
+        wrtadmin('admin.site.register(%s%s)\n' % (class_name, model_suffix ))
     wrtadmin('\n')
     models_writer.close()
     forms_writer.close()
diff --git a/django/generatedssuper.py b/django/generatedssuper.py
index daec5d6d2560594346a928b73f1c5965e2231ce9..62f4d33890ee6af636c62a12e6ab228b1c329721 100644
--- a/django/generatedssuper.py
+++ b/django/generatedssuper.py
@@ -168,8 +168,8 @@ class GeneratedsSuper(object):
         wrtforms('\nclass %s%s(forms.Form):\n' % (
             class_name, form_suffix, ))
         if cls.superclass is not None:
-            wrtmodels('    %s = models.ForeignKey("%s_model")\n' % (
-                cls.superclass.__name__, cls.superclass.__name__, ))
+            wrtmodels('    %s = models.ForeignKey("%s%s")\n' % (
+                cls.superclass.__name__, cls.superclass.__name__, model_suffix, ))
         for spec in cls.member_data_items_:
             name = spec.get_name()
             prefix, name = cls.get_prefix_name(name)
@@ -237,8 +237,8 @@ class GeneratedsSuper(object):
                 if mapped_type is not None:
                     clean_data_type = mapped_type
                 wrtmodels(
-                    '    %s = models.ForeignKey(\n        "%s_model",\n' % (
-                        name, clean_data_type, ))
+                    '    %s = models.ForeignKey(\n        "%s%s",\n' % (
+                        name, clean_data_type, model_suffix, ))
                 wrtmodels(
                     '        related_name="{}_{}_{}",\n'.format(
                         class_name, name, clean_data_type, ))
@@ -247,9 +247,9 @@ class GeneratedsSuper(object):
                         '        blank=True, null=True,\n')
                 wrtmodels('    )\n')
                 wrtforms(
-                    '    %s = forms.MultipleChoiceField(%s_model.objects'
+                    '    %s = forms.MultipleChoiceField(%s%s.objects'
                     '.all())\n' % (
-                        name, clean_data_type, ))
+                        name, clean_data_type, model_suffix, ))
         wrtmodels('\n')
         wrtmodels('    def __unicode__(self):\n')
         wrtmodels('        return "id: %s" % (self.id, )\n')
diff --git a/gends_user_methods.py b/gends_user_methods.py
index c143a35dc7880e93d8d847231ca52425079a3039..0ba8e4eb5f4dcc161ab571f395cc7e526724652a 100755
--- a/gends_user_methods.py
+++ b/gends_user_methods.py
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # -*- mode: pymode; coding: latin1; -*-
 
+from __future__ import print_function
 import sys
 import re
 
@@ -65,11 +66,11 @@ class MethodSpec(object):
         source = self.source % values_dict
         return source
     def show(self):
-        print 'specification:'
-        print '    name: %s' % (self.name, )
-        print self.source
-        print '    class_names: %s' % (self.class_names, )
-        print '    names pat  : %s' % (self.class_names_compiled.pattern, )
+        print('specification:')
+        print('    name: %s' % (self.name, ))
+        print(self.source)
+        print('    class_names: %s' % (self.class_names, ))
+        print('    names pat  : %s' % (self.class_names_compiled.pattern, ))
 
 
 #
@@ -120,7 +121,7 @@ method2 = MethodSpec(name='walk_and_show',
         global counter
         counter += 1
         depth += 1
-        print '%%d. class: %(class_name)s  depth: %%d' %% (counter, depth, )
+        print('%%d. class: %(class_name)s  depth: %%d' %% (counter, depth, ))
         members = %(class_name)s._member_data_items
         for member in members:
             s1 = member.get_name()
@@ -135,7 +136,7 @@ method2 = MethodSpec(name='walk_and_show',
                 else:
                     s4 = '<instance>'
             s5 = '%%s%%s%%s  %%s' %% (s1.ljust(16), s2.ljust(16), s3.rjust(4), s4, )
-            print '   ', s5
+            print('   ', s5)
         for member in members:
             if member.get_container():
                 for child in getattr(self, member.get_name()):
diff --git a/generateDS.html b/generateDS.html
index 11b7be4251b157571799ab67b8c9b8b8557142c3..b45e53e067732d6f590ffc05926e435fded7089b 100644
--- a/generateDS.html
+++ b/generateDS.html
@@ -220,7 +220,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.28c</td>
+<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.28d</td>
 </tr>
 </tbody>
 </table>
@@ -229,7 +229,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">date:</th><td class="field-body">October 17, 2017</td>
+<tr class="field"><th class="field-name">date:</th><td class="field-body">October 25, 2017</td>
 </tr>
 </tbody>
 </table>
@@ -982,18 +982,18 @@ session file in generateds_gui.py, the graphical front-end for
 generateDS.py.  Additional options on the command line can be
 used to override options in the session file.  A session file
 is an XML document, so you can modify it with a text editor.</dd>
-<dt>fix-type-names=&quot;oldname1:newname1;oldname2:newname2;...&quot; Fix up</dt>
-<dd><p class="first">(replace) complex type names.  Using this option will replace
-the following: (1) the 'name' attribute of a complexType; (2)
-the 'type' attribute of each element that refers to the type;
-and (3) the 'base' attribute of each extension that refers to
-the type.  These fixups happen before information is collected
-from the schema for code generation. Therefore, using this
-option is effectively equivalent to copying your schema, then
-editing it with your text editor, then generating code from the
-modified schema.  If a new name is not specified, the default is
-to replace the old name with the old name plus an added &quot;xx&quot;
-suffix.  Examples:</p>
+<dt>fix-type-names=&quot;oldname1:newname1;oldname2:newname2;...&quot;</dt>
+<dd><p class="first">Fix up (replace) complex type names.  Using this option will
+replace the following: (1) the 'name' attribute of a
+complexType; (2) the 'type' attribute of each element that
+refers to the type; and (3) the 'base' attribute of each
+extension that refers to the type.  These fixups happen before
+information is collected from the schema for code generation.
+Therefore, using this option is effectively equivalent to
+copying your schema, then editing it with your text editor, then
+generating code from the modified schema.  If a new name is not
+specified, the default is to replace the old name with the old
+name plus an added &quot;xx&quot; suffix.  Examples:</p>
 <pre class="last literal-block">
 $ generateDS.py --fix-type-names=&quot;type1:type1Aux&quot;
 $ generateDS.py --fix-type-names=&quot;type1;type2:type2Repl&quot;
@@ -3380,7 +3380,7 @@ following among others:</p>
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="generateDS.txt">View document source</a>.
-Generated on: 2017-10-17 23:02 UTC.
+Generated on: 2017-10-26 03:43 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>
diff --git a/generateDS.py b/generateDS.py
index 435cfa11665244f5b42a1d851cb09bcaf6a23eb9..767a2398c86936716ab7f8b5cf579b4263de82ee 100755
--- a/generateDS.py
+++ b/generateDS.py
@@ -227,7 +227,7 @@ logging.disable(logging.INFO)
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-VERSION = '2.28c'
+VERSION = '2.28d'
 ##VERSION##
 
 if sys.version_info.major == 2:
@@ -3795,6 +3795,10 @@ def generateBuildStandard_1(
         type_element = None
         abstract_child = False
         type_name = child.getAttrs().get('type')
+        elementDef = ElementDict.get(name)
+        if elementDef is not None:
+            if elementDef.getName() != elementDef.getType():
+                type_name = elementDef.getType()
         if type_name:
             type_element = ElementDict.get(type_name)
         if type_element and type_element.isAbstract():
diff --git a/generateDS.txt b/generateDS.txt
index 70b78ddd7be73a8647e36f650dee839c5f277e22..732fedb4507b0af4b6a17be7f8fb7e610e55a51d 100644
--- a/generateDS.txt
+++ b/generateDS.txt
@@ -12,7 +12,7 @@ generateDS -- Generate Data Structures from XML Schema
 
 .. version
 
-:revision: 2.28c
+:revision: 2.28d
 
 .. version
 
@@ -705,18 +705,18 @@ session=mysession.session
     used to override options in the session file.  A session file
     is an XML document, so you can modify it with a text editor.
 
-fix-type-names="oldname1:newname1;oldname2:newname2;..." Fix up
-    (replace) complex type names.  Using this option will replace
-    the following: (1) the 'name' attribute of a complexType; (2)
-    the 'type' attribute of each element that refers to the type;
-    and (3) the 'base' attribute of each extension that refers to
-    the type.  These fixups happen before information is collected
-    from the schema for code generation. Therefore, using this
-    option is effectively equivalent to copying your schema, then
-    editing it with your text editor, then generating code from the
-    modified schema.  If a new name is not specified, the default is
-    to replace the old name with the old name plus an added "xx"
-    suffix.  Examples::
+fix-type-names="oldname1:newname1;oldname2:newname2;..."
+    Fix up (replace) complex type names.  Using this option will
+    replace the following: (1) the 'name' attribute of a
+    complexType; (2) the 'type' attribute of each element that
+    refers to the type; and (3) the 'base' attribute of each
+    extension that refers to the type.  These fixups happen before
+    information is collected from the schema for code generation.
+    Therefore, using this option is effectively equivalent to
+    copying your schema, then editing it with your text editor, then
+    generating code from the modified schema.  If a new name is not
+    specified, the default is to replace the old name with the old
+    name plus an added "xx" suffix.  Examples::
 
         $ generateDS.py --fix-type-names="type1:type1Aux"
         $ generateDS.py --fix-type-names="type1;type2:type2Repl"
diff --git a/generateds_gui_notes.html b/generateds_gui_notes.html
index 247926899cc03767c3249890ae4190ebaa7f981e..38ecf0eae7fbf12760f7c4adee7c17e827b9bbea 100644
--- a/generateds_gui_notes.html
+++ b/generateds_gui_notes.html
@@ -220,7 +220,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.28c</td>
+<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.28d</td>
 </tr>
 </tbody>
 </table>
@@ -229,7 +229,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">date:</th><td class="field-body">October 17, 2017</td>
+<tr class="field"><th class="field-name">date:</th><td class="field-body">October 25, 2017</td>
 </tr>
 </tbody>
 </table>
@@ -401,7 +401,7 @@ $ mv generateds_gui.mo locale/ru/LC_MESSAGES/
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="generateds_gui_notes.txt">View document source</a>.
-Generated on: 2017-10-17 23:02 UTC.
+Generated on: 2017-10-26 03:43 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>
diff --git a/generateds_gui_notes.txt b/generateds_gui_notes.txt
index 3a247b8b2b5fa577803b92187f0c46a4ebbad110..9261aaee53c9f8d6c82a2cd91d5afde42201bcb2 100644
--- a/generateds_gui_notes.txt
+++ b/generateds_gui_notes.txt
@@ -12,7 +12,7 @@ GenerateDS GUI Notes
 
 .. version
 
-:revision: 2.28c
+:revision: 2.28d
 
 .. version
 
diff --git a/gui/generateds_gui.py b/gui/generateds_gui.py
index 11d4df3573219157bf8885f525c710e186b37b19..7f4ae3fdf636c08092c5b17b72820bb2bcb615d9 100644
--- a/gui/generateds_gui.py
+++ b/gui/generateds_gui.py
@@ -41,7 +41,7 @@ from libgenerateDS.gui import generateds_gui_session
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-VERSION = '2.28c'
+VERSION = '2.28d'
 ##VERSION##
 
 
diff --git a/librarytemplate_howto.html b/librarytemplate_howto.html
index 8f1804cdce4b6c47811569a03a87cd52cc082db6..6b29b61c562da8677ea50d2ca204e4f40d7085ba 100644
--- a/librarytemplate_howto.html
+++ b/librarytemplate_howto.html
@@ -217,7 +217,7 @@ dkuhlman (at) davekuhlman (dot) org
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.28c</td>
+<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.28d</td>
 </tr>
 </tbody>
 </table>
@@ -226,7 +226,7 @@ dkuhlman (at) davekuhlman (dot) org
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">date:</th><td class="field-body">October 17, 2017</td>
+<tr class="field"><th class="field-name">date:</th><td class="field-body">October 25, 2017</td>
 </tr>
 </tbody>
 </table>
@@ -380,7 +380,7 @@ this command for your needs.  For example, you may need to use
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="librarytemplate_howto.txt">View document source</a>.
-Generated on: 2017-10-17 23:02 UTC.
+Generated on: 2017-10-26 03:43 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>
diff --git a/librarytemplate_howto.txt b/librarytemplate_howto.txt
index b7c0427c77d9f02a2fa3e44b9a391b53dd65dec7..5a57e3227ba7e827202b0112d6ee373827e31dae 100644
--- a/librarytemplate_howto.txt
+++ b/librarytemplate_howto.txt
@@ -8,7 +8,7 @@ How to package a generateDS.py generated library
 
 .. version
 
-:revision: 2.28c
+:revision: 2.28d
 
 .. version
 
diff --git a/process_includes.py b/process_includes.py
index 44994d45b117799c3a6d39f9bf6ce88f51fd7195..27b5f90368938c7521fdac155ebd7243df430b14 100644
--- a/process_includes.py
+++ b/process_includes.py
@@ -40,7 +40,7 @@ except ImportError:
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-VERSION = '2.28c'
+VERSION = '2.28d'
 ##VERSION##
 
 CatalogDict = {}
diff --git a/setup.py b/setup.py
index b9cc2157da1d88bf01064b5f6ab03775cae0c704..cbbf5ee09a4011d84edfde046a217a8dcef2fb6c 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ setup(name="generateDS",
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-    version="2.28c",
+    version="2.28d",
 ##VERSION##
     author="Dave Kuhlman",
     author_email="dkuhlman@davekuhlman.org",
diff --git a/tutorial/generateds_tutorial.html b/tutorial/generateds_tutorial.html
index 3d47d0e91a63cb2ae156a0bfa2e2b9d4875a235d..db088b5aacbc798e262bd2c699aef64d63116776 100644
--- a/tutorial/generateds_tutorial.html
+++ b/tutorial/generateds_tutorial.html
@@ -219,7 +219,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.28c</td>
+<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.28d</td>
 </tr>
 </tbody>
 </table>
@@ -228,7 +228,7 @@ They are used by updateversion.py. -->
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">date:</th><td class="field-body">October 17, 2017</td>
+<tr class="field"><th class="field-name">date:</th><td class="field-body">October 25, 2017</td>
 </tr>
 </tbody>
 </table>
@@ -1210,7 +1210,7 @@ named <tt class="docutils literal">garden_api.py</tt>, you can create an instanc
 <div class="footer">
 <hr class="footer" />
 <a class="reference external" href="generateds_tutorial.txt">View document source</a>.
-Generated on: 2017-10-17 23:02 UTC.
+Generated on: 2017-10-26 03:43 UTC.
 Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>
diff --git a/tutorial/generateds_tutorial.txt b/tutorial/generateds_tutorial.txt
index a6b58d9c85d632cb8a84fc9587be461c6da57cd8..daebabc1e1227661078442ba41837bf20d8d2e59 100644
--- a/tutorial/generateds_tutorial.txt
+++ b/tutorial/generateds_tutorial.txt
@@ -11,7 +11,7 @@ generateDS -- Introduction and Tutorial
 
 .. version
 
-:revision: 2.28c
+:revision: 2.28d
 
 .. version
 
diff --git a/tutorial/generateds_tutorial.zip b/tutorial/generateds_tutorial.zip
index 676114fd0f335a01efc2f88ff7c37796030dd3ef..bd9d2b9e08cbe1ac9200b64202aed4a3bd5e44d2 100644
Binary files a/tutorial/generateds_tutorial.zip and b/tutorial/generateds_tutorial.zip differ
diff --git a/upload_pypi b/upload_pypi
index 37a8a71cc4659a1778360fbe719ac3deafc72849..7522f2de63c35d5706870aa79e763d64ffd08823 100755
--- a/upload_pypi
+++ b/upload_pypi
@@ -1,4 +1,8 @@
 #!/bin/bash -v
 # python setup.py sdist --formats=gztar upload
 # python setup.py bdist_egg upload
-python setup.py register sdist --formats=gztar bdist_egg upload
+#python setup.py register sdist --formats=gztar bdist_egg upload
+#
+# for info, see:
+#    https://packaging.python.org/tutorials/distributing-packages/#packaging-and-distributing-projects
+twine upload dist/generateDS-2.28rc0-py2.7.egg dist/generateDS-2.28rc0.tar.gz