Adding some basic structure for threads
Loop + targetchanged (we still need mutex for current position?)
Merge branch 'threads2' into threads
Mutex
Adding cleand shutdown of pthreads.
Merge branch 'threads'