Fixes for bugs exposed by NetBSD.