fix threading bugs

Fix locking of data structures shared across threads.
Merge pull request #16 from acornacorn/hydro-devel

fix threading bugs