integrate @leathrum's extensions

Fixes #1