multithreading and class refactoring

Signed-off-by: Andrea <andreatello92@gmail.com>