Moving out some code that belonged in the more general ethereum code (this lib should run standalone).