Factor the guts out so they can be unit tested separately.
Fix some rST markup.