refectoring continues

- cleaned up threading API
- another minor changes
fixed namespace wrapping
fixed condition variable waitFor