src: fix race condition when callback is invoked from thread pool

Fixes #153.
Closes #154.
src: whitespace