Fixed a ReferenceBuilder bug and made generator building a bit more
friendly.