Initial import from Reesd.

This code was written for Reesd ans is now open sourced. The commit history is
not retained as Reesd is currently a private project with a lot of other
components.