Major changes. Solved threading issues