CHanges of things, loads of debugging done
Added default value for pid in thread