added thread safe fixes.
added some design features.


Signed-off-by: Yotam Sela <yotam.sela@mail.huji.ac.il>