Brondsem patches

Patches from Dave Brondsema's fork.