Submitted by: Mark Santcroos <marks@ripe.net> Reviewed by: imp, dfr, bde
Also some minor style cleanups.
- Reduce duplicated code. PR: 50427 Submitted by: Bob Bishop <rb@gid.co.uk>