Added multithreading and made it work with python 3!