added context handling and thread safeness
new support for multthreading
new support for multthreading