Rewrited with thread classes. Need depth support and much of tests.