Refactor class

Ok, this puts the heinous ruby script in a much better place.  Breaking up everything into methods exposed some bad practices I'll work out later, but for now it looks good.