split functions into more files.
- make this compile on NetBSD/x86_64 [does not work yet] - completely automate the NetBSD header generation. This should make porting to other platforms easier.