Refactor

I has some free time over lunch so I refactored a bit of the code. Let me know if you have questions or concerns with any of the changes.

I also added cli option interface and made it into a ruby gem.