Addressed message ordering issues.
Better registration db locking.

Uses the Python 'with' construct. Also retry several times on db
unpickle to handle occasional problems due to (I think) lock
non-atomicity. Ultimately this should be fixed properly (atomic locks,
or a proper sqlite db?) - but it should be a rare thing for multiple
processes to simultaneously access a user reg db.