Major Redo

Cleaned up code, made this a little more modular.