Separated threads from main class

Cleaned up things
Thanks Teun_ for helping