Got multithreaded generation working, cleaned up code a lot