Rewrote a lot of stuff to use classes