Prototype

Needs a lot of cleanup:

 * Should not be a giant main action
 * Should separate pure and side-effecting code