More paranoid type checks.
Use reentrant functions so that code is thread safe.