added timer and thread safety

Ignore-this: cfc7d6afd6d97bee2b772b605c0ec3fc

Is it all really thread safe? probably not. need to analyze.

darcs-hash:20130430061042-c21fe-20e84ee7aa22b6d50b26919ed412abe517968772