optimizations in oiko-threads.cpp - added an aggregate to implement RAII and transfered all action there