Database improvements.

Fix creation of state and prevent multiple chains from evaluating the
same memory subsystem.