Added python3 support and multithreading.