Major testing and stability improvements.

- Implemented BK trees for managing duplicates.
- Major cleanup of optionals
- Played with alt implementation of DCT (not working)
- Improved task management