major update

- added threads
- a lot of small optimizations