Change db.py to fix bug.

Now std can be serialized in the DB totally.
Add an option is_in_memory to PE ctor.