Original code by
Bastiaan Bakker <bastiaan.bakker@lifeline.nl>

Patches applied by
Scott Cantor <cantor.2@osu.edu>
