Moved from classes to functions.

Classes were not the way to go about this. I've moved out all class
methods into functions. This should make things easier.