Wrapped all functions in classes, made constructors and simplified code