Implement tracking of Value instances.

Similiar to what was done to Handles in 8547f25753e449fe242dce757adcd1d080e8ee29,
this commit turn Values into weak references.

It eliminates errors reported by Valgrind, but might introduce
performance problems.