added main thread and some other stuff