Hook up references to reference entries.
Fix missing/bad endsect that was messing up the doc structure.