First move in isolating logic

Trying again.

Same deal: Chopped a few things up a bit to aid unit-testing and reading the logic. Also added path.Join on the theme per request.

I made a new pull request, as I was not on a new master when I made the other one, and there was a semi-nasty merge conflict, and rebase and fix of last conflict was the cleanest way to solve it. I dislike doing push --force.