Quick and dirty optimizations. Huge need for cleanup