brief code review

So you don't have to accept this pull request, it just shows how I would re-organize the code if it was my project.  I haven't dived into your actual processing yet (it takes a little bit more time to understand) but I was able to add a few things for you think about.

The first is the `if __name__ == "__main__":` pattern in python-- that's nice so that you only execute the code if you're running the file specifically, but you don't run it if you're importing the file from some other __main__

I made a class to wrap the candidate file shelve interface b/c it felt like it made more sense to package it together.

because of the if name==main pattern I also moved a lot of the "initialization" code down to that area too.

I'll probably do a second pass in the few days.  Let me know what you think!