Fix some errors and reduce differences with FreeBSD.