General improvement and cleanups, including fixes for OpenBSD.

Signed-off-by: Frank Mertens <frank@cyblogic.de>