Apply fixes from gouraud branch.
Apply fixes from gouraud branch.

The changes were verified by diffing a render from `karsten/refine-links` and
`hierarchical-refine-links`. The later includes only link refinement and the
fixes from this commit.


Former-commit-id: 51a0ba1baf0cb3403f1100b13457ad53040c35c1
jeschkies/renderer,jeschkies/renderer,blacklab/renderer,turner-renderer/turner,turner-renderer/turner,turner-renderer/turner,turner-renderer/turner