Cleaned up code. Converted sloppy scripts to OOP.