refactoring started. the init compiles
got single regions working
removed duplicate thread code
finished refactoring