Implemented selector recovery by transferring all keys to a newly created selector. Updated code so that it does not assume that the SelectionKey never changes.