Move 'restore deferred' to sessions menu

Also move the database query that does this to the session module.