NetBSD fixes. Includes fixes for gcc 4.8

github newbie so I'm unsure if I should be requesting pull requests for subsets of commits.