saugns v0.3.6d. Fix crash in generator. Clean-up changes.

Fix crashes due to wrong-sized allocation in generator.
This bug was added in v0.3.1, and not found for 5 months
because things happened to work on my systems and I've
not received any feedback from users.

Also contains a smattering of clean-up changes.
This tag has no release notes.