Lots of changes

Changed ID system to use Stacks, implemented watchdog, implemented a
task scheduler and reduced number of threads.