Some refactoring for PeerDBHandler.
More or less done with cleaning up PeerDB.