Absorb patches from Brendon Towle. Closes #22, #21, #20