Refactoring

Here is my first pass at refactoring a few things. I'll next move onto the NUnit conversion and rake tasks if this is goes over well. Let me know your thoughts.