modifying for *BSD support and additional NetBSD specific patches. This version includes some security bug fixes.