Use multiprocessing instead of threading
Add profiling