Major refactor. Code is now in logical classes that should allow easy extensibility.