Started optimizing with threads. Outline done