Fixed sampleSize bug in thread creation code and added if overhead check.